package com.yy.wga.mp.module.merchant.controller;


import com.yy.wga.common.core.dto.Result;
import com.yy.wga.common.utils.mapping.BeansUtils;
import com.yy.wga.merchant.feign.api.MerchantMomentShareFeign;
import com.yy.wga.mp.module.merchant.request.MerchantMomentShareGetRequest;
import com.yy.wga.mp.module.merchant.response.MerchantMomentShareGetResponse;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * 发圈素材
 *
 * @author guochao
 * @since 2024-10-31 22:12:53
 */
@RestController
@RequestMapping("api/merchant/momentShare")
public class MerchantMomentShareController {
    /**
     * 服务对象
     */
    @Resource
    private MerchantMomentShareFeign merchantMomentShareFeign;

    /**
     * 获取发圈素材
     * @param request
     * @return
     */
    @PostMapping("get")
    public Result<List<MerchantMomentShareGetResponse>> get(@Validated @RequestBody MerchantMomentShareGetRequest request) {
        com.yy.wga.merchant.feign.request.MerchantMomentShareGetRequest getRequest = BeansUtils.map(request, com.yy.wga.merchant.feign.request.MerchantMomentShareGetRequest.class);
        Result<List<com.yy.wga.merchant.feign.response.MerchantMomentShareGetResponse>> listResult = merchantMomentShareFeign.get(getRequest);
        if (!listResult.isSuccess()) {
            return Result.fail(listResult.getCode(), listResult.getMessage());
        }
        return Result.success(BeansUtils.mapList(listResult.getData(), MerchantMomentShareGetResponse.class));
    }
}
